package com.zzusedating.androidapp.tools;

import android.app.Activity;

import java.util.ArrayList;

public class ActivityCollector {
    private static ArrayList<Activity> activities = new ArrayList<>();

    public static void addActivity(Activity activity){
        activities.add(activity);
    }
    public static void removeActivity(Activity activity){
        activities.remove(activity);
    }
    public static void finishAll(){
        for (int i = activities.size() - 1; i >= 0; i--){
            if (!activities.get(i).isFinishing()) {
                activities.get(i).finish();
            }
        }
    }
    public static void finishFromStart(int num){
        for (int i = num - 1; i >= 0; --i){
            activities.get(i).finish();
        }
    }
    public static int size(){
        return activities.size();
    }
}
